/*
 * Copyright (c) 2010-2011 Josef Hardi <josef.hardi@gmail.com>
 * Copyright (c) 2010 Piotr Zagawa <piotr.zagawa@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package id.duapuluhdua.dakidaki.layers;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.Rect;

import id.duapuluhdua.dakidaki.common.CommonActivity;
import id.duapuluhdua.dakidaki.map.Screen;

/**
 *
 */
public class SetOfLayers extends Layer
{
  /** Fields */
  private ArrayList<Layer> mVecLayer;

  public SetOfLayers(CommonActivity parent, Screen screen)
  {
    super(parent, screen);

    mVecLayer = new ArrayList<Layer>();
    mVecLayer.add(new LayerCompass(parent, screen));
    mVecLayer.add(new LayerLocation(parent, screen));
    mVecLayer.add(new LayerInfo(parent, screen));
  }

  /**
   * @param width
   * @param height
   * @param screenOrientation
   */
  @Override
  public void surfaceSizeChanged(int width, int height, int screenOrientation)
  {
    for (int i = 0; i < mVecLayer.size(); i++) {
      mVecLayer.get(i).surfaceSizeChanged(width, height, screenOrientation);
    }
  }

  /**
   * Initializes all the layers. This method is called by the {@code MainDraw}
   * before the animation starts.
   */
  @Override
  public void initData()
  {
    for (int i = 0; i < mVecLayer.size(); i++) {
      mVecLayer.get(i).initData();
    }
  }

  @Override
  public void doDraw(Canvas canvas, Rect area)
  {
    for (int i = 0; i < mVecLayer.size(); i++) {
      mVecLayer.get(i).doDraw(canvas, area);
    }
  }

  @Override
  public void updateObjectsState()
  {
    for (int i = 0; i < mVecLayer.size(); i++) {
      mVecLayer.get(i).updateObjectsState();
    }
  }
}
